//
//  RWMyViewController.m
//  RedWine
//
//  Created by Liufangfang on 2016/12/26.
//  Copyright © 2016年 HuiBangKe. All rights reserved.
//

#import "RWMyViewController.h"
#import "RWSettingViewController.h"
#import "RWOrderListViewController.h"
#import "RWPayViewController.h"
#import "RWGiftCardViewController.h"
#import "RWMessageViewController.h"
#import "RWPersonInfoViewController.h"

@interface RWMyViewController (){

    NSArray *images;
    NSArray *titles;
    NSArray *wineNumbers;
}

@property (nonatomic, assign) CGFloat alphaMemory;

@property (nonatomic, strong) UIImageView *imageV;
@property (nonatomic, strong) UILabel *nameLab;

@end

@implementation RWMyViewController

#pragma mark - View LifeCycle

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initObjects];
    [self setNavigation];
    [self setMyUI];
    [self configNotification];
}

- (void)viewWillAppear:(BOOL)animated{
    
    [super viewWillAppear:animated];
    [self activeGiftCard];
    [_myTV reloadData];
    //使透明，注：在消失的方法里一定要写对应的非透明代码，否则返回到上一级界面，导航栏会乱掉
    [self.navigationController.navigationBar setTranslucent:YES];
    //移除透明导航栏时下面的黑线
    if ([self.navigationController.navigationBar respondsToSelector:@selector(shadowImage)]) {
        
        [self.navigationController.navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
        [self.navigationController.navigationBar setShadowImage:[[UIImage alloc] init]];
    }
    [[[self.navigationController.navigationBar subviews] objectAtIndex:0] setAlpha:_alphaMemory];
}

- (void)viewDidAppear:(BOOL)animated{

    [super viewDidAppear:animated];
    
    if ([FTYUser sharedUser].userID.length > 0) {
        
        //强制刷新TVheader数据
        _imageV.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[FTYUser sharedUser].userAvatar]]];
        
        NSString *name = [FTYUser sharedUser].userName;
        if (name == nil) {
            name = @"";
        }
        _nameLab.text = [NSString stringWithFormat:@"会员：%@", name];
        
        [self activeGiftCard];
        [_myTV reloadData];
    } else {
        [self loginAction];
    }
}

- (void)viewWillDisappear:(BOOL)animated{
    
    [super viewWillDisappear:animated];
    
    [self.navigationController.navigationBar setTranslucent:NO];
    if (_alphaMemory < 1) {
        [[[self.navigationController.navigationBar subviews] objectAtIndex:0] setAlpha:_alphaMemory];
        [UIView animateWithDuration:0.15 animations:^{
            [[[self.navigationController.navigationBar subviews] objectAtIndex:0] setAlpha:1];
        }];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Load Datas

- (void)initObjects{

    images = @[@"myorder_icon", @"wallen_icon", @"coupon_icon"];
    titles = @[@"我的订单", @"我的钱包", @"我的酒券"];
    
    NSString *wineB = [FTYUser sharedUser].userWineBalance;
    NSString *benefit = [FTYUser sharedUser].userBenefit;
    //TODO:建立一个字符串的非空工具，供后续工程使用
    if (wineB == nil) {
        wineB = @"0.00";
    }
    if (benefit == nil) {
        benefit = @"0.00";
    }
    wineNumbers = @[wineB, benefit];
}

- (void)loadDatas{
    
    //移除原UI
    if (_myTV) {
        [_myTV removeFromSuperview];
    }
    
    FTYUser *user = [FTYUser sharedUser];
    [FTYHTTPManager postInfoWithSubUrl:[NSString stringWithFormat:@"/shop/ybkapi.php?act=ybkapi&op=ybkbalance&member_id=%@&token=%@", user.userID, user.userToken] parameters:nil block:^(id result, NSError *error) {
        
        if (!error) {
            
            DLog(@"====%@", result);
            FTYBaseModel *baseModel = [[FTYBaseModel alloc] init];
            baseModel = [FTYBaseModel mj_objectWithKeyValues:result];
            FTYErrorInfoModel *errorInfo = [FTYErrorInfoModel mj_objectWithKeyValues:baseModel.err];
            
            if (0 == errorInfo.errorcode) {
                
                [self setNavigation];
                [self setMyUI];
            } else {
                [[FTYToastView alloc] addTitle:errorInfo.errorinfo addView:self.view];
            }
        } else {
            
        }
    }];
}

#pragma mark - Config UI

- (void)setNavigation{
    
    UIButton *myCountBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 70.*FTY_WIDTH_BASE, 33.*FTY_HEIGHT_BASE)];
    [myCountBtn setTitle:@"我的账户" forState:UIControlStateNormal];
    [myCountBtn setTitleColor:[FTYColor whiteColor] forState:UIControlStateNormal];
    myCountBtn.titleLabel.font = FTY_FONTTSIZE(15);
    myCountBtn.titleLabel.textAlignment = NSTextAlignmentLeft;
    UIBarButtonItem *myCountBarItem = [[UIBarButtonItem alloc] initWithCustomView:myCountBtn];
    
    self.navigationItem.leftBarButtonItem = myCountBarItem;
    
    CGRect frame = CGRectMake(0, 0, 33.*FTY_WIDTH_BASE, 33.*FTY_WIDTH_BASE);
    
    UIButton *messageBtn = [[UIButton alloc] initWithFrame:frame];
    [messageBtn setImage:[UIImage imageNamed:@"infor_icon"] forState:UIControlStateNormal];
    UIBarButtonItem *messageBarItem = [[UIBarButtonItem alloc] initWithCustomView:messageBtn];
    [messageBtn addTarget:self action:@selector(messageBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    
    UIButton *settingBtn = [[UIButton alloc] initWithFrame:frame];
    [settingBtn setImage:[UIImage imageNamed:@"set_icon"] forState:UIControlStateNormal];
    UIBarButtonItem *settingBarItem = [[UIBarButtonItem alloc] initWithCustomView:settingBtn];
    [settingBtn addTarget:self action:@selector(settingBtnAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.rightBarButtonItems = @[settingBarItem, messageBarItem];
}

- (void)setMyUI{
 
    self.automaticallyAdjustsScrollViewInsets = NO;
    _myTV = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, FTY_SCREEN_WIDTH, FTY_SCREEN_HEIGHT - FTY_TABBAR_HEIGHT) style:UITableViewStylePlain];
    [self.view addSubview:_myTV];
    _myTV.separatorStyle = UITableViewCellSeparatorStyleNone;
    _myTV.dataSource = self;
    _myTV.delegate = self;
    _myTV.scrollEnabled = NO;
    _myTV.tableHeaderView = [self createHeader];
    _myTV.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    [_myTV reloadData];
}

#pragma mark - Config Invoke Methods

- (void)messageBtnAction:(UIButton *)btn{

    //消息
    RWMessageViewController *messageVC = [[RWMessageViewController alloc] init];
    messageVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:messageVC animated:YES];
}

- (void)settingBtnAction:(UIButton *)btn{

    //设置
    RWSettingViewController *settingVC = [[RWSettingViewController alloc] init];
    settingVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:settingVC animated:YES];
}

- (UIView *)createHeader{

    UIView *headerV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FTY_SCREEN_WIDTH, 165.*FTY_WIDTH_BASE)];
    headerV.backgroundColor = [FTYColor getMainColorWithAlpha:1.];
    
    UIImageView *imageV = [[UIImageView alloc] init];
    [headerV addSubview:imageV];
    imageV.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[FTYUser sharedUser].userAvatar]]];
    imageV.layer.masksToBounds = YES;
    imageV.layer.cornerRadius = 80.*FTY_WIDTH_BASE / 2;
    imageV.layer.borderColor = [FTYColor whiteColor].CGColor;
    imageV.layer.borderWidth = 4.*FTY_WIDTH_BASE;
    imageV.userInteractionEnabled = YES;
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(avatarAction)];
    [imageV addGestureRecognizer:tapGesture];
    [imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(60.*FTY_HEIGHT_BASE);
        make.centerX.mas_equalTo(headerV.mas_centerX);
        make.width.height.mas_equalTo(80.*FTY_WIDTH_BASE);
    }];
    _imageV = imageV;
    
    NSString *name = [FTYUser sharedUser].userName;
    if (name == nil) {
        name = @"";
    }
    
    UILabel *nameLab = [[UILabel alloc] init];
    [headerV addSubview:nameLab];
    nameLab.text = [NSString stringWithFormat:@"会员：%@", name];
    nameLab.textColor = [FTYColor whiteColor];
    nameLab.font = FTY_FONTTSIZE(12);
    [nameLab sizeToFit];
    [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(imageV.mas_bottom).offset(6.*FTY_HEIGHT_BASE);
        make.centerX.mas_equalTo(headerV.mas_centerX);
    }];
    _nameLab = nameLab;
    
    return headerV;
}

#pragma mark - Notification Method

- (void)configNotification{

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(modifyPassword) name:@"ModifyPasswordSuccessNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(refreshMyinfo) name:@"RefreshLoginSuccessNotification" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(activeGiftCard) name:@"GiftCardActiveSuccessNotification" object:nil];
}

#pragma mark - Notificaiton Invoke Method

- (void)modifyPassword{

    [self loginAction];
}

- (void)refreshMyinfo {
    
    [self loadDatas];
}

//礼金卡激活后刷新个人页数据
- (void)activeGiftCard{
    
    FTYUser *user = [FTYUser sharedUser];
    [FTYHTTPManager postInfoWithSubUrl:[NSString stringWithFormat:@"/shop/ybkapi.php?act=ybkapi&op=ybkbalance&member_id=%@&token=%@", user.userID, user.userToken] parameters:nil block:^(id result, NSError *error) {
        
        if (!error) {
            
            DLog(@"====%@", result);
            FTYBaseShopCartModel *baseModel = [[FTYBaseShopCartModel alloc] init];
            baseModel = [FTYBaseShopCartModel mj_objectWithKeyValues:result];
            FTYErrorInfoModel *errorInfo = [FTYErrorInfoModel mj_objectWithKeyValues:baseModel.err];
            NSDictionary *info = [NSDictionary mj_objectWithKeyValues:baseModel.info];
            
            if (0 == errorInfo.errorcode) {
                
                [[FTYUser sharedUser] writeUserAccountBalance:[baseModel.info objectForKey:@"balance"]];
                [self.myTV reloadData];
            } else {
                [[FTYToastView alloc] addTitle:errorInfo.errorinfo addView:self.view];
            }
        } else {
            
        }
    }];
}

#pragma mark - Private Invoke Methods

- (void)avatarAction{

    if ([FTYUser sharedUser].userID.length > 0) {
        
        RWPersonInfoViewController *personInfoVC = [[RWPersonInfoViewController alloc] init];
        [self.navigationController pushViewController:personInfoVC animated:YES];
    } else {
        [self loginAction];
    }
}

- (void)loginAction{

    [FTYLoginManager reLoginFromViewController:self];
}

#pragma mark - <UITableViewDataSource>

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    if(0 == section || 2 == section){
    
        return 1;
    } else {
    
        return 2;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    return 40.*FTY_HEIGHT_BASE;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

    return 5.*FTY_HEIGHT_BASE;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *sectionHeaderV = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FTY_SCREEN_WIDTH, 20.*FTY_HEIGHT_BASE)];
    
    //顶部线
    UIView *line1 = [[UIView alloc] init];
    [sectionHeaderV addSubview:line1];
    line1.backgroundColor = [FTYColor blackColor];
    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(.5*FTY_HEIGHT_BASE);
    }];
    
    UIButton *icon = [[UIButton alloc] init];
    [sectionHeaderV addSubview:icon];
    [icon setImage:[UIImage imageNamed:images[section]] forState:UIControlStateNormal];
    [icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(sectionHeaderV.mas_centerY);
        make.left.mas_equalTo(12.*FTY_WIDTH_BASE);
        make.width.height.mas_equalTo(30.*FTY_WIDTH_BASE);
    }];
    
    UILabel *nameLab = [[UILabel alloc] init];
    [sectionHeaderV addSubview:nameLab];
    nameLab.text = titles[section];
    nameLab.textColor = [FTYColor blackColor];
    nameLab.font = FTY_FONTTSIZE(12.);
    [nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(sectionHeaderV.mas_centerY);
        make.left.mas_equalTo(icon.mas_right).offset(10.*FTY_WIDTH_BASE);
    }];
    
    //第一个section
    if (0 == section) {
        
        //添加箭头
        UIButton *arrowIcon = [[UIButton alloc] init];
        [sectionHeaderV addSubview:arrowIcon];
        [arrowIcon setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];

        //添加点击事件
        sectionHeaderV.userInteractionEnabled = YES;
        UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(myOrderTapGesture:)];
        [sectionHeaderV addGestureRecognizer:tapGesture];
    }
    
    return sectionHeaderV;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    NSInteger section = indexPath.section;
    NSInteger row = indexPath.row;
    if(0 == section){
        return 80.*FTY_HEIGHT_BASE;
    } else if(1 == section){
    
        if (0 == row) {
            return 90.*FTY_HEIGHT_BASE;
        } else {
            return 50.*FTY_HEIGHT_BASE;
        }
    } else {
        return 100.*FTY_HEIGHT_BASE;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *myID = @"myID";
    UITableViewCell *myCell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:myID];
    myCell.selectionStyle = UITableViewCellSelectionStyleNone;
    
    NSInteger section = indexPath.section;
    NSInteger row = indexPath.row;
    
    //=====公共部分
    //顶部线
    UIView *line1 = [[UIView alloc] init];
    [myCell addSubview:line1];
    line1.backgroundColor = [FTYColor blackColor];
    [line1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.mas_equalTo(0);
        make.height.mas_equalTo(.5*FTY_HEIGHT_BASE);
    }];
    
    //底部线
    if (1 == section && 0 == row) {
        
    } else {
        
        UIView *line2 = [[UIView alloc] init];
        [myCell addSubview:line2];
        line2.backgroundColor = [FTYColor blackColor];
        [line2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.bottom.right.mas_equalTo(0);
            make.height.mas_equalTo(.5*FTY_HEIGHT_BASE);
        }];
    }

    NSArray *orderImages = @[@"wallet_icon", @"receiving", @"myorder_icon"];
    NSArray *orderNames = @[@"待付款", @"待收货", @"全部订单"];
    
    //各个section
    switch (section) {
            
        case 0:{
            
            //我的订单
            for (int i=0; i<3; i++) {
                
                CGFloat btn_Width = FTY_SCREEN_WIDTH / 3;
                UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
                [myCell addSubview:btn];
                btn.frame = CGRectMake(0 + btn_Width * i, 0, btn_Width, CGRectGetHeight(myCell.frame));
                [btn setImage:[UIImage imageNamed:orderImages[i]] forState:UIControlStateNormal];
                [btn setTitle:orderNames[i] forState:UIControlStateNormal];
                [btn setTitleColor:[FTYColor grayColor] forState:UIControlStateNormal];
                //图片在上，文字在下
                [btn setTitleEdgeInsets:UIEdgeInsetsMake(btn.imageView.frame.size.height + 30.*FTY_HEIGHT_BASE, -btn.imageView.frame.size.width - 40.*FTY_HEIGHT_BASE, .0, .0)];
                btn.titleLabel.font = FTY_FONTTSIZE(12.);
                [btn setAdjustsImageWhenHighlighted:NO];
                btn.tag = 200 + i;
                [btn addTarget:self action:@selector(orderButtonAction:) forControlEvents:UIControlEventTouchUpInside];
            }
            break;
        }
        case 1:{
            
            //我的钱包
            if (0 == row) {
                
                NSString *accountBenefit = [FTYUser sharedUser].userAccountBalance;
                if (accountBenefit == nil) {
                    accountBenefit = @"0.00";
                }
                
                UILabel *moneyLab = [[UILabel alloc] init];
                [myCell addSubview:moneyLab];
                moneyLab.text = accountBenefit;
                moneyLab.textColor = [FTYColor getMainColorWithAlpha:1.];
                moneyLab.font = FTY_FONTTSIZE(32);
                [moneyLab sizeToFit];
                [moneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.mas_equalTo(10.*FTY_HEIGHT_BASE);
                    make.centerX.mas_equalTo(myCell.mas_centerX);
                }];
                
                UILabel *moneyFlagLab = [[UILabel alloc] init];
                [myCell addSubview:moneyFlagLab];
                moneyFlagLab.text = @"账户余额(元)";
                moneyFlagLab.textColor = [FTYColor blackColor];
                moneyFlagLab.font = FTY_FONTTSIZE(12.);
                [moneyFlagLab sizeToFit];
                [moneyFlagLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.mas_equalTo(moneyLab.mas_bottom).offset(10.*FTY_HEIGHT_BASE);
                    make.centerX.mas_equalTo(myCell.mas_centerX);
                }];
            } else {
            
                NSArray *moneyRow2Titles = @[@"去充值", @"礼卡金激活"];
                for (int i = 0; i< 2; i++) {
                    
                    CGFloat btn_Width = FTY_SCREEN_WIDTH / 2;
                    UIButton *btn = [[UIButton alloc] init];
                    [myCell addSubview:btn];
                    btn.frame = CGRectMake(0 + btn_Width * i, 0, btn_Width, CGRectGetHeight(myCell.frame));
                    [btn setTitle:moneyRow2Titles[i] forState:UIControlStateNormal];
                    [btn setTitleColor:[FTYColor grayColor] forState:UIControlStateNormal];
                    btn.titleLabel.font = FTY_FONTTSIZE(12.);
                    btn.tag = 250 + i;
                    [btn addTarget:self action:@selector(moneyRow2BtnAction:) forControlEvents:UIControlEventTouchUpInside];
                }
                
                //中间分隔线
                UIView *midLine = [[UIView alloc] init];
                [myCell addSubview:midLine];
                midLine.backgroundColor = [FTYColor grayColor];
                [midLine mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.bottom.mas_equalTo(0);
                    make.left.mas_equalTo(FTY_SCREEN_WIDTH/2);
                    make.width.mas_equalTo(.5*FTY_WIDTH_BASE);
                }];
            }
            break;
        }
        case 2:{
            
            NSArray *numberFlags = @[@"酒券余额(元)", @"七天累计收益"];
            
            for (int i=0; i<2; i++) {
                
                CGFloat lab_Width = FTY_SCREEN_WIDTH / 2;
                
                UILabel *numberLab = [[UILabel alloc] init];
                [myCell addSubview:numberLab];
                numberLab.text = wineNumbers[i];
                numberLab.textAlignment = NSTextAlignmentCenter;
                numberLab.textColor = [FTYColor getMainColorWithAlpha:1.];
                numberLab.font = FTY_FONTTSIZE(15);
                [numberLab sizeToFit];
                [numberLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.mas_equalTo(20.*FTY_HEIGHT_BASE);
                    make.left.mas_equalTo(0 + lab_Width * i);
                    make.width.mas_equalTo(lab_Width);
                }];
                
                UILabel *numberFlagLab = [[UILabel alloc] init];
                [myCell addSubview:numberFlagLab];
                numberFlagLab.text = numberFlags[i];
                numberFlagLab.textAlignment = NSTextAlignmentCenter;
                numberFlagLab.textColor = [FTYColor grayColor];
                numberFlagLab.font = FTY_FONTTSIZE(12);
                [numberFlagLab sizeToFit];
                [numberFlagLab mas_makeConstraints:^(MASConstraintMaker *make) {
                    make.top.mas_equalTo(numberLab.mas_bottom).offset(20.*FTY_HEIGHT_BASE);
                    make.left.mas_equalTo(0 + lab_Width * i);
                    make.width.mas_equalTo(lab_Width);
                }];
            }
            break;
        }
        default:
            break;
    }

    return myCell;
}

#pragma mark - <UITableViewDelegate>



#pragma mark - Private Invoke Methods

- (void)myOrderTapGesture:(UITapGestureRecognizer *)tap{

    //全部订单
    [self gotoAllOrder];
}

- (void)orderButtonAction:(UIButton *)btn{

    switch (btn.tag) {
        case 200:
            //待付款
            [self gotoPayOrder];
            break;
        case 201:
            //待收货
            [self gotoReceiveOrder];
            break;
        case 202:
            //全部订单
            [self gotoAllOrder];
            break;
            
        default:
            break;
    }
}

- (void)gotoAllOrder{
    
    RWOrderListViewController *orderListVC = [[RWOrderListViewController alloc] init];
    orderListVC.hidesBottomBarWhenPushed = YES;
    orderListVC.tableTitle = @"全部订单";
    orderListVC.orderState = @"all";
    [self.navigationController pushViewController:orderListVC animated:YES];
}

- (void)gotoPayOrder{

    RWOrderListViewController *orderListVC = [[RWOrderListViewController alloc] init];
    orderListVC.hidesBottomBarWhenPushed = YES;
    orderListVC.tableTitle = @"待付款";
    orderListVC.orderState = @"10";
    [self.navigationController pushViewController:orderListVC animated:YES];
}

- (void)gotoReceiveOrder{

    RWOrderListViewController *orderListVC = [[RWOrderListViewController alloc] init];
    orderListVC.hidesBottomBarWhenPushed = YES;
    orderListVC.tableTitle = @"待收货";
    orderListVC.orderState = @"30";
    [self.navigationController pushViewController:orderListVC animated:YES];
}

- (void)moneyRow2BtnAction:(UIButton *)btn{

    switch (btn.tag) {
        case 250:{
            //去充值
            RWPayViewController *payVC = [[RWPayViewController alloc] init];
            payVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:payVC animated:YES];
            break;
        }
        case 251:{
            //礼卡金激活
            RWGiftCardViewController *giftCardVC = [[RWGiftCardViewController alloc] init];
            giftCardVC.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:giftCardVC animated:YES];
            break;
        }
        default:
            break;
    }
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
